package com.lottoad.android.cronos.c2dm;

import android.content.Context;
import android.os.PowerManager;
import android.util.Log;

/**
 * PushWake(Push가 오면 화면 활성화)
 * @author Administrator
 *
 */
class PushWakeLock {

	private static PowerManager.WakeLock sCpuWakeLock;

	static void acquireCpuWakeLock(Context context) {

		Log.e("PushWakeLock", "Acquiring cpu wake lock");
		if (sCpuWakeLock != null) {
			return;
		}

		PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);

		sCpuWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK |
															PowerManager.ACQUIRE_CAUSES_WAKEUP |
															PowerManager.ON_AFTER_RELEASE, "I'm your father");
		sCpuWakeLock.acquire();
	}

	static void releaseCpuLock() {

		Log.e("PushWakeLock", "Releasing cpu wake lock");

		if (sCpuWakeLock != null) {
			sCpuWakeLock.release();
			sCpuWakeLock = null;
		}
	}
}
